﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'GetMenusByContenedor')
	BEGIN
		DROP  Procedure  GetMenusByContenedor
	END

GO

CREATE Procedure GetMenusByContenedor

	(
		@contenedorID int = NULL
	)

AS

BEGIN
	SET NOCOUNT ON
	
	IF @contenedorID IS NULL
		SELECT
		[Descripcion],
		[Estado],
		[IdMenu],
		[IdMenudPadre],
		[Namespace],
		[Nombre]
		FROM [Menus]
		WHERE [IdMenudPadre] IS NULL
	ELSE
		SELECT
		[Descripcion],
		[Estado],
		[IdMenu],
		[IdMenudPadre],
		[Namespace],
		[Nombre]
		FROM [Menus]
		WHERE [IdMenudPadre]=@contenedorID

	SET NOCOUNT OFF
END

GO


GRANT EXEC ON GetMenusByContenedor TO PUBLIC

GO


